package com.tanhua.tanhua.controller;

import com.tanhua.tanhua.service.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("dashboard")
public class DashboardController {

    @Autowired
    DashboardService dashboardService;

    @Value("${jwt.secret}")
    private String secret;
    @GetMapping("summary")
    public ResponseEntity<Object> dashboard(@RequestHeader("Authorization") String token){


        Map map = dashboardService.finddashboarddata(token);

        if (map!=null){
            return ResponseEntity.ok(map);

        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }

}